package com.xmg.p2p.base.controller;

import com.xmg.p2p.base.query.PageResult;
import com.xmg.p2p.base.util.BidConst;
import com.xmg.p2p.business.query.BidRequestQueryObject;
import com.xmg.p2p.business.service.IBidRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * lcd  2020/5/25
 * Description:
 */
@Controller
public class IndexController {
    @Autowired
    private IBidRequestService bidRequestService;

    @RequestMapping("index")
    public String index(Model model){
        model.addAttribute("bidRequests", bidRequestService.listIndex(5));
        return "main";
    }

    @RequestMapping("invest")
    public String investIndex(){
        return "invest";
    }

    @RequestMapping("invest_list")
    public String investList(BidRequestQueryObject qo,Model model){
        qo.setBidRequestStates(new int[]{BidConst.BIDREQUEST_STATE_BIDDING,BidConst.BIDREQUEST_STATE_PAYING_BACK,BidConst.BIDREQUEST_STATE_COMPLETE_PAY_BACK});
        model.addAttribute("pageResult", bidRequestService.queryPage(qo));
        return "invest_list";
    }
}
